package cn.maxwell._02_asyn;


import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * 同步消息生产者
 */
public class Producer {
    public static void main(String[] args) throws Exception{
        //1.创建生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("asyn-producer-group");
        //2.设置namesrv地址
        producer.setNamesrvAddr("localhost:9876");
        //3.开启生产者producer实例
        producer.start();
        //4.设置消息
        Message message = new Message("asyn", "maxwell", "泥炉煮酒共君享！".getBytes(StandardCharsets.UTF_8));
        //5.发送消息
        System.out.println(producer.send(message));
        //6.关闭生产者实例
    }
}
